# Copyright (c) 2024-2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_custom_target(all_sub_timer_test ALL)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeout"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_cleartimeout
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testClearTimeout"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_setinterval
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetInterval"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_with_delay_minus_one
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutWithDelayMinusOne"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_clearcleartimeout_with_different_id
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testClearTimeoutWithDifferentId"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_cleartimeout_by_clearInterval
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testClearTimeoutByClearInterval"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_clearclearinterval_with_different_id
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testClearIntervaltWithDifferentId"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_clearinterval_by_cleartimeout
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testClearIntervalByClearTimeout"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_execute_order
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutExecuteOrder"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_execute_order1
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutExecuteOrder1"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_cost_time
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testCallingSetTimeoutCostTime"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_nested
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutNested"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_setinterval_nested
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetIntervalNested"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_and_setinterval_nested
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutAndSetIntervalNested"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_with_async_callback
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutWithAsyncCallback"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_with_launch_callback
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutWithLaunchCallback"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_settimeout_with_EAworker_callback
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".testSetTimeoutWithEAWorkerCallback"
)

panda_ets_interop_js_test_arkjsvm(ets_interop_js_test_normal_test
    ETS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/timer_tests.sts
    JS_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/run_timer_test.js
    LAUNCHER_ARGS ".normalTest"
)

set(sub_targets
    ets_interop_js_test_settimeout
    ets_interop_js_test_cleartimeout 
    ets_interop_js_test_setinterval
    ets_interop_js_test_settimeout_with_delay_minus_one 
    ets_interop_js_test_clearcleartimeout_with_different_id
    ets_interop_js_test_cleartimeout_by_clearInterval 
    ets_interop_js_test_clearclearinterval_with_different_id
    ets_interop_js_test_clearinterval_by_cleartimeout
    ets_interop_js_test_settimeout_execute_order
    ets_interop_js_test_settimeout_execute_order1
    ets_interop_js_test_settimeout_cost_time 
    ets_interop_js_test_settimeout_nested 
    ets_interop_js_test_setinterval_nested
    ets_interop_js_test_settimeout_and_setinterval_nested
    ets_interop_js_test_settimeout_with_async_callback
    ets_interop_js_test_settimeout_with_launch_callback
    ets_interop_js_test_settimeout_with_EAworker_callback
    )

add_dependencies(all_sub_timer_test ${sub_targets})